Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

corrected wrong link #112

Merged
merged 3 commits into from
Sep 20, 2024
Merged

corrected wrong link #112

merged 3 commits into from
Sep 20, 2024

Conversation

gdnathan
Copy link
Contributor

Before we merge this PR, I would like to discuss this comment:
src/network/wire/lib.zig

    // I believe it's safe. No payload will be longer than u32.MAX
    const payload_len: u32 = @intCast(payload.len);

As stated in the bitcoin documentation, "The current maximum number of bytes (“MAX_SIZE”) allowed in the payload by Bitcoin Core is 32 MiB—messages with a payload size larger than this will be dropped or rejected."

So, I removed the "I believe" part, as 32 * 1024 * 1024 < u32::MAX

To actually enforce the limit, we could do something like this maybe:

const MAX_PAYLOAD_SIZE: u32 = 32 * 1024 * 1024

const payload_len: u32 = @intCast(payload.len);
if (payload_len > MAX_PAYLOAD_SIZE) {
    return someerror
}

Is it worth opening an issue for ?

Copy link
Collaborator

@tdelabro tdelabro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please do open an issue, or even push a new PR to enforce the max payload size

@tdelabro tdelabro merged commit 15f24e2 into zig-bitcoin:main Sep 20, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants